1. Field of the Invention
The present invention relates to an image processing apparatus, method, program, and recording medium. More particularly, the present invention relates to an image processing apparatus, method, program, and recording medium capable of correcting defective pixels in a line state or in a block state by a simple and small-sized configuration at a low cost.
2. Description of the Related Art
A solid-state imaging device, such as a CCD (Charge Coupled Device) image sensor, a CMOS (Complementary Metal Oxide Semiconductor) image sensor, etc., is used for a digital camera and a video camera.
These image sensors sometimes include a defective pixel which generates no electronic signals, or which outputs only a constant-level signal all the time because of a problem at the time of production, etc. The present applicant has proposed a method of correcting such a defective pixel before (for example, Japanese Unexamined Patent Application Publication No. 2004-228931).
A description will be given of the above-described proposed principle with reference to FIGS. 1 and 2. Assume that an imaging section includes three sheets of image sensors each of which is dedicated for red (R), green (G), and blue (B), and one pixel of a green image sensor among them is a defective pixel outputting only the value 250 all the time out of the values 0 to 255.
In such a case, a plurality of the other pixels adjacent to the defective pixel are provided for correcting the defective pixel. In the example in FIG. 1, the three pixels (pixel-1, pixel-2, and pixel-3) in the immediately adjacent upper line, and the pixels (pixel-4 and pixel-5) adjacent to the right and left in the same line are provided for the defective pixel-0. In this regard, in FIG. 1, numbers represent the values of individual colors. For example, the pixel value R0 of red of the defective pixel-0 is 59, the pixel value G0 of green is 250, and the pixel value B0 of blue is 48. Also, the pixel value R1 of red of the pixel-1 is 78, the pixel value G1 of green is 63, and the pixel value B1 of blue is 63.
First, a pixel that resembles the defective pixel is obtained. For colors (in this case, red and blue) other than the color (in this case, green) of a defective pixel out of the three colors, the sum of the absolute value of the differences with adjacent pixels is calculated, and the pixel corresponding to the minimum value is assumed to be the most similar pixel.
Specifically, as shown in FIG. 2, the difference dr in red is 19 (=78−59), and the difference db in blue is 15 (=63−48) between defective pixel-0 and pixel-1. The difference in red dr is 132 (=191−59), and the difference in blue db is 130 (=178−48) between the defective pixel-0 and pixel-2. The difference in red dr is 161 (=220−59), and the difference in blue db is 161 (=209−48) between the defective pixel-0 and pixel-3. The difference in red dr is 62 (=121−59), and the difference in blue db is 62 (=110−48) between the defective pixel-0 and pixel-4. The difference in red dr is 148 (=207−59), and the difference in blue db is 145 (=193−48) between the defective pixel-0 and pixel-5.
Accordingly, the sum of the absolute values of the difference in two colors for the pixels 1 to 5 are 34 (=19+15), 262 (=132+130), 322 (=161+161), 124 (=62+62), 293 (148+145), respectively. The minimum value thereof is 34 of pixel-1, and thus pixel-1 is the most similar pixel to the defective pixel-0.
Next, the difference is obtained between the green value of pixel-1, which is the most similar pixel to the defective pixel-0, and the average value of the sum of the absolute values of the differences. The obtained value becomes the value of the defective color of the defective pixel. Specifically, the value of green of pixel-1 is 63, and the average value of the sum of the difference absolute values is 17 (=34/2), and thus the corrected value becomes 46 (=63−17). Accordingly, the output of the three colors R, G, and B of the defective pixel becomes 59, 46, and 48, respectively.
In this manner, by correcting a defective pixel, it becomes possible not to discard an image sensor having a defective pixel and to effectively use it.